import request from '@/utils/request'

// 获取门锁列表
export function getLockList(query) {
  return request({
    url: '/lock/lock/list',
    method: 'get',
    params: query
  })
}

export function getLockUnitList(query) {
  return request({
    url: '/lock/unit/list2',
    method: 'get',
    params: query
  })
}
// 获取门锁详情
export function getLockDetail(id) {
  return request({
    url: '/lock/lock/' + id,
    method: 'get'
  })
}

// 添加门锁
export function addLock(data) {
  return request({
    url: '/lock/lock',
    method: 'post',
    data: data
  })
}

// 修改门锁
export function updateLock(data) {
  return request({
    url: '/lock/lock',
    method: 'put',
    data: data
  })
}

export function resetAdminPassword(data) {
  return request({
    url: '/lock/device/update',
    method: 'put',
    data: {
      mac: data.mac,
      isReset: 0
    }
  })
}
// 删除门锁
export function deleteLock(id) {
  return request({
    url: '/lock/lock/' + id,
    method: 'delete'
  })
}

// 远程开锁
export function remoteLockOpen(lockMac) {
  return request({
    url: '/lock/lock/open',
    method: 'get',
    params: { lockMac }
  })
}

// 远程关锁
export function remoteLockClose(lockMac) {
  return request({
    url: '/lock/lock/close',
    method: 'get',
    params: { lockMac }
  })
}

// 获取锁状态
export function getLockStatus(lockMac) {
  return request({
    url: '/lock/lock/status',
    method: 'get',
    params: { lockMac }
  })
}

// 重置门锁
export function resetLock(lockMac) {
  return request({
    url: '/lock/lock/reset',
    method: 'get',
    params: { lockMac }
  })
}

// 同步门锁时间
export function syncLockTime(lockMac) {
  return request({
    url: '/lock/lock/syncTime',
    method: 'get',
    params: { lockMac }
  })
}

// 获取锁电量
export function getLockBattery(lockMac) {
  return request({
    url: '/lock/lock/battery',
    method: 'get',
    params: { lockMac }
  })
}

// 获取锁操作日志
export function getLockOperationLogs(query) {
  return request({
    url: '/lock/lock/operationLogs',
    method: 'get',
    params: query
  })
}

// 重启门锁
export function restartLock(lockMac) {
  return request({
    url: '/lock/lock/restart',
    method: 'get',
    params: { lockMac }
  })
}

// 获取门锁二维码
export function getLockQrcode(data) {
  return request({
    url: '/lock/lock/qrcode',
    method: 'post',
    data: data
  })
}
